#pragma once
#include"INet.h"
#include<list>
#include<map>

class TcpServer :public INet
{
public:
	TcpServer(INetMediator* pMediator);
	~TcpServer();
	bool InitNet();
	//关闭网络
	void UnInitNet();
	//发送数据
	bool SendData(long ISendIp, char* buf, int nLen);//IP地址,BUf(具体发生数据的内容),长度

protected:
	//接收数据
	void RecvData();

	SOCKET m_sockListen;

	static unsigned int __stdcall AcceptThread(void* lpvoid);
	static unsigned int __stdcall RecvThread(void* lpvoid);

	list<HANDLE> m_hThreadHandleList;	//保存所有句柄的list
	map<unsigned int, SOCKET> m_mapThreadIdToSocket;	//保存客户端线程id和对应的socket

	bool  m_isStop;

};
